The 20 Games Challenge
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage


Pac-Man changed the arcade industry when it released in 1980. At the time, most developers were focused on the space shooter genre that Space Invaders started. Designer Toru Iwatani didn’t want arcades to only attract boys and men, so he made a game that was colorful and fun enough to appeal to women and children as well.

Pac-Man featured the most complex AI to be seen in the arcade so far. The ghosts followed a set of extremely simple rules, but those rules combined to make the ghosts seem intelligent and strategic.



  • Create the Pac-Man maze. Place a score and high score counter above the level, and a life counter below. The maze operates on a grid. There is a tunnel that allows Pac-Man and the ghosts to wrap across the screen, appearing on the other side.
    • Fill the maze with dots and four large dots (Power Pellets). Each cell in the grid will contain a dot or power pellet.
  • Create Pac-Man himself. He should be able to move in four directions through the maze. When Pac-Man collides with a dot, he will eat it, increasing the score.
  • Add four ghosts. They will chase Pac-Man through the level. The ghosts start in a “pen” and are released after enough dots are eaten. Each ghost will cycle between “chase mode” and “scatter mode.” During chase mode, the ghosts will move toward specific cells to give the illusion of teamwork and intelligence.
    • Red ghost “Blinky” will target Pac-Man directly.
    • Pink ghost “Pinky” will try to get 4 tiles in front of Pac-Man.
    • Blue ghost “Inky” will target a special position. Draw a line from Blinky’s position to the cell two tiles in front of Pac-Man, then double the length of the line. That is Inky’s target position.
    • Orange ghost “Clyde” will target Pac-Man directly, but will scatter whenever he gets within an 8 tile radius of Pac-Man.
    • Each ghost has an assigned corner that it will scatter to during scatter mode.
    • For more details on the Pac-Man AI, check out this detailed breakdown. If you are using a modern game engine, then you will probably solve some problems (such as pathfinding) differently and will therefore have to improvise a little.
  • Add the “power pellet” mode. When Pac-man eats the pellet, the ghosts will turn blue (scared), and will scatter. Pac-Man can eat the ghosts. After a timer elapses, the ghosts will flash white, then return to normal. Eaten ghosts will award points, turn into eyes, and then return to the pen before coming back as regular ghosts.
  • Add the win states and lose states. Pac-Man will die when eaten by a ghost, consuming a life. When all dots are consumed, the level will reset.

Stretch goal:

  • Feel free to customize the maze, add more/different AI behaviors, or add more levels.
  • Add fruit pickups. Fruit appears after enough dots are eaten, and awards bonus points. (This is a stretch goal because I forgot about it until now…)

You’re not the first person to attempt this challenge! Check out some completed games below!

Don’t forget to share your progress on the community discord!

I’ll periodically update this section with community submissions. Feel free to message me if you want yours to be included. You can also open a pull request yourself to add your game, or someone else’s.